package com.eclab.hello.model;

import com.eclab.hello.imodelview.UserDetailView;
import com.eclab.hello.imodelview.UserSimpleView;
import com.eclab.hello.validator.MyConstraint;
import com.fasterxml.jackson.annotation.JsonView;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Past;
import java.io.Serializable;
import java.util.Date;


/**
 * 描述:
 * 用户
 * @author yd
 * @create 2019-05-28 15:19
 */
@Data
@Entity
@Table(name = "user")
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "User")
public class User implements Serializable {

    private static final long serialVersionUID = -3629784071225214583L;


    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @JsonView(UserSimpleView.class)
    @ApiModelProperty(value = "用户ID")
    private Integer id;

    @JsonView(UserSimpleView.class)
    @ApiModelProperty(value = "用户名")
    @MyConstraint(message = "自定义校验未通过")
    @Column(name = "username", unique = true, nullable = false, length = 64)
    private String username;

    @JsonView(UserDetailView.class)
    @ApiModelProperty(value = "用户密码")
    @NotBlank(message = "密码必填")
    @Column(name = "password", length = 64)
    private String password;

    @JsonView(UserSimpleView.class)
    @ApiModelProperty(value = "生日")
    @Past(message = "生日必须是过去的时间")
    @Column(name = "brithday", length = 6)
    private Date brithday;



}
